<?php 
namespace Admin\Controller;
class AdminController extends BaseController{
	//职员后台账号管理
	function admin_role(){
		$adminOb=M('manager');
		$adminRole=$adminOb->where('level>1')
							->order('id desc')
							->select();
		$this->assign('adminRole',$adminRole);
		$this->display();
	}
	function admin_role_del(){
		$id=$_GET['id'];
		
		$adminOb=M('manager');
		$re=$adminOb->where("id=$id")
					->delete();
		if($re){
			echo $id;
		}
	}
	//管理员权限
	function admin_permission(){
		$this->display();
	}
	//管理员管理
	function admin_list(){
		$adminOb=M('manager');
		$admin_list=$adminOb->where('level=1')
							->order('level asc')
							->select();
		$this->assign('admin_list',$admin_list); 
		$this->display();
	}
	//管理员添加
	function admin_add(){
		$this->display();
	}	
	function admin_manager_add(){
		$adminOb=M('manager');
		unset($_POST['password2']);
		$_POST['password']=MD5($_POST['password']);
		var_dump($_POST);
		$re=$adminOb->data($_POST)
					->add();
					
		if($re){
			
			$this->success('添加成功');
		}else{
			$this->error("$message");
		}
	}

		//1-管理员停止

	
	function admin_stop(){
		$id=$_GET['id'];
		$adminOb=M('manager');
		$data=array(
			'status'=>'0'
			);
		$admin_stop=$adminOb->where("id=$id")
							->data($data)
							->save();
		if($admin_stop){
			echo $id; 
		} 
	}
		//2-管理员开启
	function admin_start(){
		$id=$_GET['id'];
		$adminOb=M('manager');
		$data=array(
			'status'=>'1',
			);
		$admin_start=$adminOb->where("id=$id")
							->data($data)
							->save();
		if($admin_start){
			echo $id;
		}	
	}
		//3-管理员删除
	function admin_del(){
		$id=$_GET['id'];
		$adminOb=M('manager');
		$admin_del=$adminOb->where("id=$id")
							->delete();
		if($admin_del){
			echo $id;
		}
	}
}